<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('标签列表')" />
	<th:block th:include="include :: select2-css" />
</head>
<body class="gray-bg">
	<div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="type-form">
					<div class="select-list">
						<ul>
							<li>
								标签名称：<input type="text" name="tagName"/>
							</li>
							<li>
								栏目：<select name="cloumnCode">
								    <option value="">所有</option>
									<option th:each="col : ${cols}" th:text="${col.name}" th:value="${col.code}"></option>
								</select>
							</li>
							<li class="select-time">
								<label>创建时间： </label>
								<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
								<span>-</span>
								<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	       <div class="btn-group-sm" id="toolbar" role="group">
	            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:dict:add">
	                <i class="fa fa-plus"></i> 新增
	            </a>
	            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:dict:edit">
		            <i class="fa fa-edit"></i> 修改
		        </a>
				<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:dict:remove">
		            <i class="fa fa-remove"></i> 删除
		        </a>
			   <a class="btn btn-success" onclick="addSearch()">
				   <i class="fa fa-plus"></i> 新增搜索标签
			   </a>
	        </div>
	        
	        <div class="col-sm-12 select-table table-striped">
			    <table id="bootstrap-table"></table>
			</div>
		</div>
	</div>
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: select2-js" />
	<script th:inline="javascript">
		var editFlag = [[${@permission.hasPermi('system:dict:edit')}]];
		var listFlag = [[${@permission.hasPermi('system:dict:list')}]];
		var removeFlag = [[${@permission.hasPermi('system:dict:remove')}]];
		var datas = [[${@dict.getType('sys_normal_disable')}]];
		var prefix = ctx + "system/tag";

		$(function() {
		    var options = {
		        url: prefix + "/list",
		        createUrl: prefix + "/add",
		        updateUrl: prefix + "/edit/{id}",
		        removeUrl: prefix + "/remove",
		        exportUrl: prefix + "/export",
		        sortName: "createTime",
		        sortOrder: "desc",
		        modalName: "标签",
		        columns: [{
		            checkbox: true
		        },
		        {
		            field: 'id',
		            title: '标签主键'
		        },
		        {
		            field: 'cloumnCode',
		            title: '栏目编码',
		            visible: false
		        },
		        {
		            field: 'tagName',
		            title: '标签名称',
		            sortable: false
		        },
		        {
		            field: 'columnName',
		            title: '所属栏目',
		            sortable: false
		        },
		        {
		            field: 'remark',
		            title: '备注'
		        },
		        {
		            field: 'createTime',
		            title: '创建时间',
		            sortable: false
		        },
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		                var actions = [];
						if(row.cloumnCode == 'TFA' || row.cloumnCode == 'TZJ' || row.cloumnCode == 'TXQ' || row.cloumnCode == 'TWT'){
							actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="editorTag(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
						}else{
							actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
						}
		                actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
		                return actions.join('');
		            }
		        }]
		    };
		    $.table.init(options);
		});

		/*字典列表-详细*/
		function detail(id) {
		    var url = prefix + '/detail/' + id;
		    $.modal.openTab("标签数据", url);
		}

		function addSearch(){
			var url = prefix + '/search/add/';
		    $.modal.openFull("添加搜索标签", url);
		}

		function editorTag(data){
		    var url = prefix + '/search/edit/' + data;
			$.modal.openFull("标签详情", url);
		}
	</script>
</body>
</html>